Prediction image generation device, moving image decoding device, moving image encoding device, and prediction image generation method

ABSTRACT

A moving image decoding method for generating prediction images by a device is provided. First and second prediction image are generated. Bidirectional prediction gradient change prediction processing is performed by using a first shift value and difference values of horizontally neighboring samples and vertically neighboring samples in the first and second prediction images to generate a first, second, third and fourth gradient images. Motion information is derived by using the first and second prediction images, the first, second, third and fourth gradient images, a second shift value, and a third shift value. Motion compensation correction value is derived by using the motion information and the first, second, third and the fourth gradient images. The third prediction image is generated by using the first and second prediction images and the motion compensation correction value. The first, second and third shift values are derived based on a pixel bit length of eight.

CROSS-REFERENCE TO RELATED APPLICATION(S)

This application is a continuation application of U.S. patentapplication Ser. No. 17/298,177, filed on May 28, 2021, which is anational stage application of International Patent Application SerialNo. PCT/JP2019/048520, filed on Dec. 11, 2019, which claims the benefitof and priority to JP Patent Application Serial No. 2018-232640, filedon Dec. 12, 2018, and JP Patent Application Serial No. 2019-000704,filed on Jan. 7, 2019. The contents of all of the above-mentionedapplications are hereby incorporated herein fully by reference in theirentirety.

TECHNICAL FIELD

Embodiments of the present invention relate to a prediction imagegeneration device, a moving image decoding device, a moving imageencoding device, and a prediction image generation method.

BACKGROUND

For the purposes of transmitting or recording moving images efficiently,a moving image encoding device is used to generate encoded data byencoding a moving image, and a moving image decoding device is used togenerate a decoded image by decoding the encoded data.

Specific moving image encoding schemes include, for example, H.264/AVC,High-Efficiency Video Coding (HEVC), etc.

In such moving image encoding schemes, images (pictures) forming amoving image are managed by a hierarchical structure, and areencoded/decoded for each CU, wherein the hierarchical structure includesslices acquired by splitting the images, Coding Tree Units (CTUs)acquired by splitting the slices, coding units (sometimes also referredto as Coding Units (CUs)) acquired by splitting the coding tree units,and Transform Units (TUs) acquired by splitting the coding units.

In addition, in such moving image encoding schemes, sometimes, aprediction image is generated on the basis of local decoded imagesacquired by encoding/decoding input images, and prediction errors(sometimes also referred to as “difference images” or “residual images”)acquired by subtracting the prediction image from the input images(original images) are encoded. Prediction image generation methodsinclude inter-picture prediction (inter-frame prediction) andintra-picture prediction (intra-frame prediction).

Further, moving image encoding and decoding technologies of recent yearsinclude non-patent document 1. Non-patent document 2 discloses a BIOtechnique in which gradient images are used to improve image qualityduring derivation of a prediction image from motion compensation(interpolation image) employing bidirectional prediction.

PRIOR ART DOCUMENTS Non-Patent Documents

-   Non-patent document 1: “Versatile Video Coding (Draft 3)”,    JVET-L1001, Joint Video Exploration Team JVET) of ITU-T SG 16 WP 3    and ISO/IEC JTC 1/SC 29/WG 11, 2018-   Non-patent document 2: “CE9-related: Complexity Reduction and    Bit-width Control for Bi-directional Optical Flow (BIO)”,    JVET-L0256, Joint Video Exploration Team (JVET) of ITU-T SG 16 WP 3    and ISO/IEC JTC 1/SC 29/WG 11, 2018

SUMMARY Problems to be Solved by the Invention

In addition to including a specific pixel bit length, predictionemploying BIO processing (BIO prediction) in non-patent document 2 inwhich gradient images are used to improve image quality duringderivation of a prediction image has reduced encoding efficiency. Inaddition, in the BIO processing, units for reading blocks occurrepeatedly; therefore, filling processing needs to be performed outsidethe coding units.

Technical Solutions

In a first aspect of the present disclosure, the moving image decodingdevice according to one solution of the present invention ischaracterized by: using, from two interpolation images, bidirectionalgradient change processing in which a prediction image is generatedaccording to a gradient change, and having a prediction image generationportion having: an L0, L1 prediction generation portion, wherein in thebidirectional gradient change processing, an L0 prediction image and anL1 prediction image for each coding unit are generated from the twointerpolation images; a gradient image generation portion, forgenerating four gradient images in a horizontal direction and a verticaldirection from the L0 prediction image and L1 prediction image; arelevant parameter calculation portion, for calculating relevantparameters of each processing unit according to product and sumoperation on the L0 prediction image, the L1 prediction image, and thefour gradient images; a motion compensation correction value derivationportion, for deriving, from the gradient images and the relevantparameters, a value for correcting a bidirectional prediction image; anda bidirectional prediction image generation portion, for generating aprediction image according to the L0 prediction image, the L1 predictionimage, and the motion compensation correction value, wherein in thegradient image generation portion and the relevant parameter calculationportion, in order to control calculation accuracy of the calculation ofrelevant parameters to be less than a certain value, an internal bitlength is configured, the internal bit length is configured to be lessthan the maximum pixel bit length that can be decoded by the decodingdevice, and the values of the L0 prediction image, the L1 predictionimage, and the gradient prediction images are right-shifted according tothe internal bit length.

In addition, the moving image decoding device according to one solutionof the present invention is characterized in that in the motioncompensation correction value derivation portion, in order to controlcalculation accuracy of the calculation to be less than a certain value,clipping processing in a value corresponding to the internal bit lengthis performed.

In a second aspect of the present disclosure, a moving image decodingdevice for generating prediction images is provided. The moving imagedecoding device includes prediction image generation circuitry forgenerating a first prediction image and a second prediction image;gradient image generation circuitry for performing bidirectionalprediction gradient change prediction processing by: generating a firstgradient image by calculating a first difference value of twohorizontally neighboring samples of each of a plurality of currentsamples of the first prediction image, wherein calculating the firstdifference value includes performing a first right shifting by a firstshift value of six, generating a second gradient image by calculating asecond difference value of two vertically neighboring samples of each ofthe plurality of current samples of the first prediction image, whereincalculating the second difference value includes performing a secondright shifting by the first shift value, generating a third gradientimage by calculating a third difference value of two horizontallyneighboring samples of each of a plurality of current samples of thesecond prediction image, wherein calculating the third difference valueincludes performing a third right shifting by the first shift value, andgenerating a fourth gradient image by calculating a fourth differencevalue of two vertically neighboring samples of each of the plurality ofcurrent samples of the second prediction image, wherein calculating thefourth difference value includes performing a fourth right shifting bythe first shift value; motion compensation correction value derivationcircuitry that: use the first prediction image, the second predictionimage, and a second shift value of four to generate a first intermediateimage, use the first gradient image, the third gradient image, and athird shift value of one to generate a second intermediate image, usethe second gradient image, the fourth gradient image, and the thirdshift value to generate a third intermediate image, use the firstintermediate image, the second intermediate image, and the thirdintermediate image to derive motion information, and use the motioninformation, the first gradient image, the second gradient image, thethird gradient image, and the fourth gradient image to derive a motioncompensation correction value; and prediction image generation circuitrythat use the first prediction image, the second prediction image, andthe motion compensation correction value to generate a third predictionimage. The first shift value, the second shift value, and the thirdshift value are derived based on a pixel bit length bitDepth of eight.

In a third aspect of the present disclosure, a moving image decodingmethod for generating prediction images is provided. The moving imagedecoding method includes generating a first prediction image and asecond prediction image; performing bidirectional prediction gradientchange prediction processing by: generating a first gradient image bycalculating a first difference value of two horizontally neighboringsamples of each of a plurality of current samples of the firstprediction image, wherein calculating the first difference valueincludes performing a first right shifting by a first shift value ofsix, generating a second gradient image by calculating a seconddifference value of two vertically neighboring samples of each of theplurality of current samples of the first prediction image, whereincalculating the second difference value includes performing a secondright shifting by the first shift value, generating a third gradientimage by calculating a third difference value of two horizontallyneighboring samples of each of a plurality of current samples of thesecond prediction image, wherein calculating the third difference valueincludes performing a third right shifting by the first shift value, andgenerating a fourth gradient image by calculating a fourth differencevalue of two vertically neighboring samples of each of the plurality ofcurrent samples of the second prediction image, wherein calculating thefourth difference value includes performing a fourth right shifting bythe first shift value; using the first prediction image, the secondprediction image, and a second shift value of four to generate a firstintermediate image; using the first gradient image, the third gradientimage, and a third shift value of one to generate a second intermediateimage; using the second gradient image, the fourth gradient image, andthe third shift value to generate a third intermediate image; using thefirst intermediate image, the second intermediate image, and the thirdintermediate image to derive motion information; using the motioninformation, the first gradient image, the second gradient image, thethird gradient image, and the fourth gradient image to derive a motioncompensation correction value; and using the first prediction image, thesecond prediction image, and the motion compensation correction value togenerate a third prediction image. The first shift value, the secondshift value, and the third shift value are derived based on a pixel bitlength bitDepth of eight.

Beneficial Effect

According to the above configurations, any one of the problems describedabove can be solved.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a schematic diagram showing components of an imagetransmission system according to this embodiment.

FIGS. 2A to 2B are diagrams showing components of a transmitting deviceequipped with a moving image encoding device according to thisembodiment and components of a receiving device equipped with a motionimage decoding device according to this embodiment. FIG. 2A shows atransmitting device equipped with a moving image encoding device, andFIG. 2B shows a receiving device equipped with a moving image decodingdevice.

FIGS. 3A to 3B are diagrams showing components of a recording deviceequipped with a moving image encoding device according to thisembodiment and a reproducing device equipped with a moving imagedecoding device according to this embodiment. FIG. 3A shows a recordingdevice equipped with a moving image encoding device, and FIG. 3B shows areproducing device equipped with a moving image decoding device.

FIGS. 4A to 4F are diagrams showing a hierarchical structure of data inan encoded stream.

FIGS. 5A to 5G are diagrams showing an example of CTU splitting.

FIGS. 6A to 6B are conceptual diagrams showing an example of a referencepicture and a reference picture list.

FIG. 7 is a schematic diagram showing components of a moving imagedecoding device.

FIG. 8 is a schematic diagram showing components of an inter-frameprediction parameter decoding portion.

FIGS. 9A to 9B are schematic diagrams showing components of a mergeprediction parameter derivation portion and components of an AMVPprediction parameter derivation portion.

FIG. 10 is a schematic diagram showing components of an inter-frameprediction image generation portion.

FIG. 11 is a diagram showing an example of a flowchart illustrating aprocedure of derivation of a prediction image performed by a motioncompensation portion having a motion compensation function and using BIOprediction according to this embodiment.

FIG. 12 is a schematic diagram showing components of a BIO portionaccording to this embodiment.

FIG. 13 is a diagram showing an example of a region where a BIO portionperforms BIO filling according to this embodiment.

FIG. 14 is a diagram showing an example of a unit for performing BIOprocessing and a reading region of a BIO portion of this embodiment.

FIG. 15 is a block diagram showing components of a moving image encodingdevice.

FIG. 16 is a schematic diagram showing components of an inter-frameprediction parameter encoding portion.

DETAILED DESCRIPTION First Embodiment

Embodiments of the present invention are described below with referenceto the accompanying drawings.

FIG. 1 is a schematic diagram showing components of an imagetransmission system 1 according to this embodiment.

The image transmission system 1 is a system for transmitting an encodedstream acquired by encoding an encoding object image, decoding thetransmitted encoded stream, and displaying an image. Components of theimage transmission system 1 include: a moving image encoding device(image encoding device) 11, a network 21, a moving image decoding device(image decoding device) 31, and a moving image display device (imagedisplay device) 41.

An image T is inputted to the moving image encoding device 11.

The network 21 transmits encoded streams Te generated by the movingimage encoding device 11 to the moving image decoding device 31. Thenetwork 21 is the Internet, a Wide Area Network (WAN), a Local AreaNetwork (LAN), or a combination thereof. The network 21 is notnecessarily limited to a bidirectional communication network, and may bea unidirectional communication network for transmitting broadcast wavessuch as terrestrial digital broadcasting and satellite broadcasting. Inaddition, the network 21 may also be replaced with a storage medium inwhich the encoded streams Te are recorded, such as Digital VersatileDisc (DVD, registered trademark), Blue-ray Disc (BD, registeredtrademark), etc.

The moving image decoding device 31 decodes the encoded streams Tetransmitted by the network 21 respectively to generate one or aplurality of decoded images Td.

The moving image display device 41 displays all of or part of the one orthe plurality of decoded images Td generated by the moving imagedecoding device 31. The moving image display device 41 includes, forexample, display apparatuses such as a liquid crystal display, anorganic Electro-Luminescence (EL) display, etc. The display may be inthe form of, for example, a stationary display, a mobile display, anHMD, etc. In addition, when the moving image decoding device 31 has highprocessing capabilities, an image having high image quality isdisplayed, and when the moving image decoding device 31 has onlyrelatively low processing capabilities, an image not requiring highprocessing capabilities and high display capabilities is displayed.

<Operator>

The operators used in this specification are described below.

>> denotes right-shift; << denotes left-shift; & denotes bitwise AND; |denotes bitwise OR; |=denotes an OR assignment operator; ∥ denoteslogical sum.

x?y:z is a ternary operator for taking y if x is true (other than 0) andtaking z if x is false (0).

Clip3(a, b, c) is a function for clipping c to a value equal to orgreater than a and equal to or less than b, and returning a if c<a,returning b if c>b, and returning c otherwise (where a<=b).

abs(a) is a function for returning the absolute value of a.

Int(a) is a function for returning the integer value of a.

floor(a) is a function for returning the greatest integer equal to orless than a.

ceil(a) is a function for returning the least integer equal to orgreater than a.

a/d denotes division of a by d (chop off decimal).

a{circumflex over ( )}b notes a to the power of b.

sign(a) is a function for returning the sign of a.sign(a)=a>0?1:a==0?0:−1

log 2(a) is a function for returning the logarithm of a to base 2.

Max(a, b) is a function for returning a if a>=b and returning b if a<b.

Min(a, b) is a function for returning a if a<=b and returning b if a>b.

Round(a) is a function for returning a rounded value of a.Round(a)=sign(a)×floor(abs(a)+0.5).

<Structure of the Encoded Stream Te>

Prior to detailed description of the moving image encoding device 11 andthe moving image decoding device 31 according to this embodiment, a datastructure of the encoded stream Te generated by the moving imageencoding device 11 and decoded by the moving image decoding device 31 isdescribed.

FIGS. 4A to 4F are diagrams showing a hierarchical structure of data inthe encoded stream Te. The encoded stream Te exemplarily includes asequence and a plurality of pictures forming the sequence. Parts (a)-(f)in FIG. 4 are diagrams respectively illustrating an encoding videosequence of a default sequence SEQ, an encoding picture defining apicture PICT, an encoding slice defining a slice S, encoding slice datadefining slice data, a coding tree unit included in the encoding slicedata, and a coding unit included in the coding tree unit.

(Encoding Video Sequence)

In the encoding video sequence, a set of data to be referred to by themoving image decoding device 31 in order to decode the sequence SEQ of aprocessing object is defined. The sequence SEQ is shown FIG. 4A, andincludes a video parameter set, a Sequence Parameter Set (SPS), aPicture Parameter Set (PPS), a picture PICT, and SupplementalEnhancement Information (SEI).

In the video parameter set VPS, in a moving image formed by a pluralityof layers, a set of encoding parameters common to a plurality of movingimages, a plurality of layers included in the moving image, and a set ofencoding parameters related to each of the layers are defined.

In the sequence parameter set SPS, a set of encoding parameters referredto by the moving image decoding device 31 in order to decode an objectsequence are defined. For example, the width and the height of a pictureare defined. It should be noted that there may be a plurality of SPSs.In this case, any one of the plurality of SPSs is selected from the PPS.

In the picture parameter set PPS, a set of encoding parameters referredto by the moving image decoding device 31 in order to decode eachpicture in the object sequence are defined. For example, a referencevalue (pic_init_qp_minus26) of a quantization width for decoding of thepicture and a flag (weighted_pred_flag) for indicating application ofweighted prediction are included. It should be noted that there may be aplurality of PPSs. In this case, any one of the plurality of PPSs isselected from each picture in the object sequence.

(Encoding Picture)

In the encoding picture, a set of data referred to by the moving imagedecoding device 31 in order to decode the picture PICT of the processingobject is defined. The picture PICT is shown FIG. 4B, and includes slice0 to slice NS−1 (NS is the total number of slices included in thepicture PICT).

It should be noted that in the following description, when it is no needto distinguish between slice 0 to slice NS−1, subscripts of the numeralsmay be omitted. In addition, other pieces of data included in theencoded stream Te and having a subscript to be described below followthe same rules.

(Encoding Slice)

In the encoding slice, a set of data referred to by the moving imagedecoding device 31 in order to decode a slice S of the processing objectis defined. The slice is shown FIG. 4C, and includes a slice header andslice data.

The slice header includes an encoding parameter group referred to by themoving image decoding device 31 in order to determine a decoding methodof an object slice. Slice type designation information (slice_type) fordesignating a slice type is an example of an encoding parameter includedin the slice header.

Examples of slice types that can be designated by the slice typedesignation information include (1) I slice using only intra-frameprediction during encoding, (2) P slice using unidirectional predictionor intra-frame prediction during encoding, (3) B slice usingunidirectional prediction, bidirectional prediction, or intra-frameprediction during encoding, and the like. It should be noted that theinter-frame prediction is not limited to unidirectional prediction andbidirectional prediction, and more reference pictures can be used togenerate a prediction image. P slice and B slice used hereinafter referto a slice including a block on which inter-frame prediction can beused.

It should be noted that the slice header may also include a reference(pic_parameter_set_id) to the picture parameter set PPS.

(Encoding Slice Data)

In the encoding slice data, a set of data referred to by the movingimage decoding device 31 in order to decode slice data of the processingobject is defined. The slice data is shown FIG. 4D, and includes a CTU.The CTU is a block of a fixed size (for example, 64×64) forming a slice,and is also referred to as a Largest Coding Unit (LCU).

(Coding Tree Unit)

In FIG. 4E, a set of data referred to by the moving image decodingdevice 31 in order to decode the CTU of the processing object isdefined. The CTU is split by recursive Quad Tree (QT) split, Binary Tree(BT) split, or Ternary Tree (TT) split into coding units CU serving as abasic unit of encoding processing. The BT split and the TT split arecollectively referred to as Multi Tree (MT) split. Nodes of a treestructure acquired by means of recursive quad tree split are referred toas coding nodes. Intermediate nodes of a quad tree, a binary tree, and aternary tree are coding nodes, and the CTU itself is also defined as ahighest coding node.

A CT includes the following information used as CT information: a QTsplit flag (qt_split_cu_flag) for indicating whether to perform QTsplit, an MT split flag (mtt_split_cu_flag) for indicating whether MTsplit exists, an MT split direction (mtt_split_cu_vertical_flag) forindicating a split direction of the MT split, and an MT split type(mtt_split_cu_binary_flag) for indicating a split type of the MT split.qt_split_cu_flag, mtt_split_cu_vertical_flag, andmtt_split_cu_binary_flag are transmitted for each coding node.

FIGS. 5A to 5G are diagrams showing an example of CTU splitting. Whenqt_split_cu_flag is 1, the coding node is split into four coding nodes(FIG. 5B).

When qt_split_cu_flag is 0, and mtt_split_cu_flag is 0, the coding nodeis not split, and one CU is maintained as a node (FIG. 5A). The CU is anend node of the coding nodes, and is not subjected to further splitting.The CU is a basic unit of the encoding processing.

When mtt_split_cu_flag is 1, MT split is performed on the coding node asfollows. When mtt_split_cu_vertical_flag is 0, andmtt_split_cu_binary_flag is 1, the coding node is horizontally splitinto two coding nodes (FIG. 5D); when mtt_split_cu_vertical_flag is 1,and mtt_split_cu_binary_flag is 1, the coding node is vertically splitinto two coding nodes (FIG. 5C). Furthermore, whenmtt_split_cu_vertical_flag is 0, and mtt_split_cu_binary_flag is 0, thecoding node is horizontally split into three coding nodes (FIG. 5F);when mtt_split_cu_vertical_flag is 1, and mtt_split_cu_binary_flag is 0,the coding node is vertically split into three coding nodes (FIG. 5E).These splits are illustrated in FIG. 5G.

In addition, when the size of the CTU is 64×64 pixels, the size of theCU may be any one of 64×64 pixels, 64×32 pixels, 32×64 pixels, 32×32pixels, 64×16 pixels, 16×64 pixels, 32×16 pixels, 16×32 pixels, 16×16pixels, 64×8 pixels, 8×64 pixels, 32×8 pixels, 8×32 pixels, 16×8 pixels,8×16 pixels, 8×8 pixels, 64×4 pixels, 4×64 pixels, 32×4 pixels, 4×32pixels, 16×4 pixels, 4×16 pixels, 8×4 pixels, 4×8 pixels, and 4×4pixels.

(Coding Unit)

As shown FIG. 4F, a set of data referred to by the moving image decodingdevice 31 in order to decode the coding unit of the processing object isdefined. Specifically, the CU consists of a CU header CUH, predictionparameters, transform parameters, quantization and transformcoefficients, etc. In the CU header, a prediction mode and the like aredefined.

Prediction processing may be performed for each CU, and may be performedfor each sub-CU acquired by further splitting the CU. When the CU andthe sub-CU have the same size, one sub-CU is included in the CU. Whenthe CU has a size larger than the size of the sub-CU, the CU is splitinto sub-CUs. For example, when the CU is 8×8 and the sub-CU is 4×4, theCU is split into four sub-CUs with two horizontal splits and twovertical splits.

Prediction types (prediction modes) include intra-frame prediction andinter-frame prediction. The intra-frame prediction is prediction in thesame picture, and the inter-frame prediction refers to predictionprocessing performed between mutually different pictures (for example,between display time points).

Processing in transform/quantization portion is performed for each CU,but the quantization and transform coefficient may also be subjected toentropy coding for each sub-block of 4×4 and the like.

(Prediction Parameters)

The prediction image is derived by prediction parameters associated withthe block. The prediction parameters include prediction parameters forthe intra-frame prediction and the inter-frame prediction.

The prediction parameters for the inter-frame prediction are describedbelow. The inter-frame prediction parameters consist of prediction listuse flags predFlagL0 and predFlagL1, reference picture indices refIdxL0and refIdxL1, and motion vectors mvL0 and mvL1. The prediction list useflags predFlagL0 and predFlagL1 are flags for indicating whetherreference picture lists respectively referred to as an L0 list and an L1list are used, and a corresponding reference picture list is used whenthe value of the prediction list use flag is 1. It should be noted thatin the present specification, when “a flag for indicating whether XX” isdescribed, a flag other than 0 (for example, 1) indicates XX, and a flagequal to 0 indicates not XX; in logical negation, logical product, andthe like, 1 is treated as true, and 0 is treated as false (the samerules are used below). However, other values may be used as the truevalue or the false value in an actual device and method.

Syntax elements for deriving the inter-frame prediction parametersinclude, for example, an affine flag affine_flag, a merge flagmerge_flag, a merge index merge_idx, an inter-frame predictionidentifier inter_pred_idc, a reference picture index refldxLX, aprediction vector index mvp_LX_idx, a difference vector mvdLX, and amotion vector accuracy mode amvr_mode.

(Reference Picture List)

The reference picture list is a list consisting of reference picturesstored in a reference picture memory 306. FIGS. 6A to 6B are conceptualdiagrams showing an example of a reference picture and a referencepicture list. In part FIG. 6A, the rectangle denotes a picture, thearrow denotes a reference relation of the picture, the horizontal axisdenotes time, I, P, and B in the rectangle respectively denote anintra-frame picture, a unidirectional prediction picture, and abidirectional prediction picture, and the numbers in the rectangledenote a decoding order. As shown of FIG. 6A, a picture decoding orderis 10, P1, B2, B3, B4, and a picture display order is 10, B3, B2, B4,P1. of FIG. 6B shows an example of a reference picture list of thepicture B3 (object picture). The reference picture list is a listdenoting candidates of the reference pictures, and one picture (slice)may have one or more reference picture lists. In the example in thefigure, the object picture B3 has two reference picture lists, namely anL0 list RefPicList0 and an L1 list RefPicList1. In each CU, thereference picture index refldxLX designates one picture in the referencepicture list RefPicListX (X=0 or 1) actually used for reference. Thefigure shows an example where refIdxL0=2 and refIdxL1=0. It should benoted that LX is a description method used in the case in which the L0prediction and the L1 prediction are not distinguished, and in thefollowing, parameters for the L0 list and parameters for the L1 list isdistinguished by replacing LX with L0 and L1.

(Merge Prediction and AMVP Prediction)

Prediction parameter decoding (encoding) methods include a mergeprediction (merge) mode and an Advanced Motion Vector Prediction orAdaptive Motion Vector Prediction (AMVP) mode, and the merge flagmerge_flag is for identifying the same. The merge prediction mode is amode for deriving from the prediction parameters of a processedneighboring block and using the same without including the predictionlist use flag predFlagLX (or the inter-frame prediction identifierinter_pred_idc), the reference picture index refldxLX, and the motionvector mvLX in the encoded data. The AMVP mode is a mode in which theinter-frame prediction identifier inter_pred_idc, the reference pictureindex refldxLX, and the motion vector mvLX are included in the encodeddata. It should be noted that the motion vector mvLX is encoded as aprediction vector index mvp_LX_idx for identifying the prediction vectormvpLX, a difference vector mvdLX, and a motion vector accuracy modeamvr_mode. In addition, in addition to the merge prediction mode, anaffine prediction mode in which identification is performed by means ofthe affine flag affine_flag may also be used. Implementations of themerge prediction mode include a skip mode in which identification isperformed by means of a skip flag skip_flag. It should be noted that theskip mode refers to a mode in which prediction parameters are derivedand used by the same method used in the merge mode and a predictionerror (residual image) is not included in the encoded data. That is,when the skip flag skip_flag is 1, an object CU includes only the skipflag skip_flag, the merge index merge_idx, and other syntax associatedwith the merge mode, and the motion vector and the like are not includedin the encoded data. Therefore, when the object CU instructs the skipflag skip_flag to use the skip mode, decoding of prediction parametersother than the skip flag skip_flag is not performed.

(Motion Vector)

The motion vector mvLX denotes an amount of deviation between blocks ontwo different pictures. A prediction vector and a difference vectorrelated to the motion vector mvLX are respectively referred to as aprediction vector mvpLX and a difference vector mvdLX.

(Inter-Frame Prediction Identifier Inter_Pred_Idc and Prediction ListUse Flag predFlagLX)

The inter-frame prediction identifier inter_pred_idc is a value forindicating the types and the number of reference pictures, and takes anyvalue of PRED_L0, PRED_L1, and PRED_BI. PRED_L0 and PRED_L1 respectivelyindicate that unidirectional prediction of a reference picture managedin the L0 list is used and that unidirectional prediction of a referencepicture managed in the L1 list is used. PRED_BI indicates thatbidirectional prediction BiPred of two reference pictures managed in theL0 list and the L1 list is used.

The merge index merge_idx is an index indicating whether any one ofprediction parameters in prediction parameter candidates (mergecandidates) derived from a block on which processing has been completedis used as a prediction parameter of an object block.

A relationship between the inter-frame prediction identifierinter_pred_idc and the prediction list use flags predFlagL0 andpredFlagL1 can be mutually converted as follows.

inter_pred_idc=(predFlagL1<<1)+predFlagL0

predFlagL0=inter_pred_idc&1

predFlagL1=inter_pred_idc>>1

(Determination on Bidirectional Prediction biPred)

A flag biPred for determining bidirectional prediction biPred can bederived depending on whether two prediction list use flags are both 1.For example, derivation can be performed by means of the followingequation.

biPred=(predFlagL0==1&&predFlagL1==1)

Alternatively, the flag biPred can also be derived depending on whetherthe inter-frame prediction identifier is a value indicating that twoprediction lists (reference pictures) are used. For example, derivationcan be performed by means of the following equation.

biPred=(inter_pred_idc==PRED_BI)?1:0

(Components of the Moving Image Decoding Device)

Components of the moving image decoding device 31 (FIG. 7 ) according tothis embodiment are described.

The components of the moving image decoding device 31 include: anentropy decoding portion 301, a parameter decoding portion (predictionimage decoding device) 302, a loop filter 305, a reference picturememory 306, a prediction parameter memory 307, a prediction imagegeneration portion (prediction image generation device) 308, an inversequantization/inverse transform portion 311, and an addition portion 312.It should be noted that according to the moving image encoding device 11described below, the moving image decoding device 31 may not include theloop filter 305.

The parameter decoding portion 302 further includes a header decodingportion 3020, a CT information decoding portion 3021, and a CU decodingportion 3022 (prediction mode decoding portion) not shown in the figure,and the CU decoding portion 3022 further includes a TU decoding portion3024. The above components can also be collectively referred to as adecoding module. The header decoding portion 3020 decodes parameter setinformation such as the VPS, the SPS, and the PPS and the slice header(slice information) from the encoded data. The CT information decodingportion 3021 decodes the CT from the encoded data. The CU decodingportion 3022 decodes the CU from the encoded data. When the TU includesthe prediction error, the TU decoding portion 3024 decodes QP updateinformation (quantization correction value) and a quantizationprediction error (residual_coding) from the encoded data.

In addition, the parameter decoding portion 302 is configured to includean inter-frame prediction parameter decoding portion (prediction imagegeneration device) 303 and an intra-frame prediction parameter decodingportion 304 not shown in the figure. The prediction image generationportion 308 is configured to include an inter-frame prediction imagegeneration portion (prediction image generation device) 309 and anintra-frame prediction image generation portion 310.

In addition, an example in which the CTU and the CU are used asprocessing units is described below; however, the processing is notlimited thereto, and processing may also be performed in units ofsub-CUs. Alternatively, the CTU and the CU may be replaced with blocks,and the sub-CU may be replaced with a sub-block; processing may beperformed in units of blocks or sub-blocks.

The entropy decoding portion 301 performs entropy decoding on theencoded stream Te inputted from the external, and decodes each code(syntax element).

The entropy decoding portion 301 outputs the decoded code to theparameter decoding portion 302. The decoded code is, for example, theprediction mode predMode, the merge flag merge_flag, the merge indexmerge_idx, the inter-frame prediction identifier inter_pred_idc, thereference picture index refIdxLX, the prediction vector indexmvp_LX_idx, the difference vector mvdLX, the motion vector accuracy modeamvr_mode, etc. Control of which code to decode is performed on thebasis of an instruction of the parameter decoding portion 302.

(Components of the Inter-Frame Prediction Parameter Decoding Portion)

The inter-frame prediction parameter decoding portion 303 decodes theinter-frame prediction parameter by referring to the predictionparameter stored in the prediction parameter memory 307 and on the basisof the code inputted from the entropy decoding portion 301. In addition,the inter-frame prediction parameter decoding portion 303 outputs thedecoded inter-frame prediction parameter to the prediction imagegeneration portion 308, and stores the same in the prediction parametermemory 307.

FIG. 8 is a schematic diagram showing the components of the inter-frameprediction parameter decoding portion 303 according to this embodiment.The inter-frame prediction parameter decoding portion 303 is configuredto include: a merge prediction portion 30374, a DMVR portion 30375, asub-block prediction portion (affine prediction portion) 30372, an MMVDprediction portion (motion vector derivation portion) 30376, a triangleprediction portion 30377, an AMVP prediction parameter derivationportion 3032, and an addition portion 3038. The merge prediction portion30374 is configured to include a merge prediction parameter derivationportion 3036. The AMVP prediction parameter derivation portion 3032, themerge prediction parameter derivation portion 3036, and the affineprediction portion 30372 are commonly used in a moving image encodingdevice and a moving image decoding device, and therefore, thesecomponents can also be collectively referred to as a motion vectorderivation portion (motion vector derivation device).

The inter-frame prediction parameter decoding control portion 303instructs the entropy decoding portion 301 to decode syntax elementsassociated with the inter-frame prediction to extract the syntaxelements included in the encoded data, and the syntax elements are, forexample, the affine flag affine_flag, the merge flag merge_flag, themerge index merge_idx, the inter-frame prediction identifierinter_pred_idc, the reference picture index refIdxLX, the predictionvector index mvp_LX_idx, the difference vector mvdLX, and the motionvector accuracy mode amvr_mode.

When the affine flag affine_flag is 1, namely, in the affine predictionmode, the affine prediction portion 30372 derives the inter-frameprediction parameter of the sub-block.

When the merge flag merge_flag is 1, namely, in the merge predictionmode, the merge index merge_idx is decoded and outputted to the mergeprediction parameter derivation portion 3036.

When the merge flag merge_flag is 0, namely, in the AMVP predictionmode, examples of AMVP prediction parameters including the inter-frameprediction identifier inter_pred_idc, the reference picture indexrefIdxLX, the prediction vector index mvp_lX_idx, and the differencevector mvdLX are decoded. The AMVP prediction parameter derivationportion 3032 derives the prediction vector mvpLX according to theprediction vector index mvp_LX_idx. In the addition portion 3038, thederived prediction vector mvpLX is added to the difference vector mvdLXso as to derive the motion vector mvLX.

(Affine Prediction Portion)

The affine prediction portion 30372 derives affine prediction parametersof the object block. In this embodiment, as the affine predictionparameter, motion vectors (mv0_x, mv0_y) and (mv1_x, mv1_y) of twocontrol points (V0, V1) of the object block are derived. Specifically,the motion vector of each control point can be derived by performingprediction according to a motion vector of a block adjacent to theobject block; alternatively, the motion vector of each control point mayalso be derived from the sum of a prediction vector derived as themotion vector of the control point and the difference vector derivedfrom the encoded data.

It should be noted that the affine prediction portion 30372 mayappropriately derive parameters for 4-parameter MVD affine prediction or6-parameter MVD affine prediction.

(Merge Prediction)

FIG. 9A is a schematic diagram showing components of the mergeprediction parameter derivation portion 3036 included in the mergeprediction portion 30374. The merge prediction parameter derivationportion 3036 includes a merge candidate derivation portion 30361 and amerge candidate selection portion 30362. It should be noted that themerge candidate is configured to include the prediction list use flagpredFlagLX, the motion vector mvLX, and the reference picture indexrefIdxLX, and is stored in a merge candidate list. An index is assigned,according to a prescribed rule, to the merge candidate stored in themerge candidate list.

The merge candidate derivation portion 30361 directly uses the motionvector of a decoded adjacent block and the reference picture indexrefIdxLX to derive the merge candidate. In addition, the merge candidatederivation portion 30361 may use spatial merge candidate derivationprocessing, temporal merge candidate derivation processing, combinedmerge candidate derivation processing, and zero merge candidatederivation processing described below.

In the spatial merge candidate derivation processing, the mergecandidate derivation portion 30361 reads, according to a prescribedrule, the prediction parameters stored in the prediction parametermemory 307, and configures the same to be merge candidates. In areference picture designation method, the merge candidates are, forexample, prediction parameters of each adjacent block within apredefined range from the object block (for example, all of or part ofblocks adjacent to a left A1, a right B1, an upper right B0, a lowerleft A0, and an upper left B2 of the object block). These mergecandidates are referred to as A1, B1, B0, A0, and B2.

Here, A1, B1, B0, A0, and B2 are motion information respectively derivedfrom blocks including the following coordinates.

A1: (xCb−1, yCb+cbHeight−1)B1: (xCb+cbWidth−1, yCb−1)B0: (xCb+cbWidth, yCb−1)A0: (xCb−1, yCb+cbHeight)B2: (xCb−1, yCb−1)

In the temporal merge derivation processing, the merge candidatederivation portion 30361 reads, from the prediction parameter memory307, prediction parameters of a lower right CBR of the object block or ablock C in a reference image including center coordinates, configuresthe same to be merge candidates Col, and stores the same in a mergecandidate list mergeCandList[ ].

A combined derivation portion derives a combined candidate avgK, andstores the same in the merge candidate list mergeCandList[ ].

The merge candidate derivation portion 30361 derives zero mergecandidates Z0 . . . ZM of which the reference picture index refIdxLX is0 . . . M and an X component and a Y component of the motion vector mvLXare both 0, and stores the same in the merge candidate list.

The merge candidate derivation portion 30361 or the combined derivationportion stores the merge candidates in the merge candidate listmergeCandList[ ] in an order of, for example, the spatial mergecandidates (A1, B1, B0, A0, B2), the temporal merge candidates Col, thecombined candidate AvgK, and the zero merge candidates ZeroCandK. Itshould be noted that unavailable reference blocks (blocks forintra-frame prediction, etc.) are not stored in the merge candidatelist.

i=0if (availableFlagA1)

mergeCandList[i++]=A1

if (availableFlagB1)

mergeCandList[i++]=B1

if (availableFlagB0)

mergeCandList[i++]=B0

if (availableFlagA0)

mergeCandList[i++]=A0

if (availableFlagB2)

mergeCandList[i++]=B2

if (availableFlagCol)

mergeCandList[i++]=Col

if (availableFlagAvgK)

mergeCandList[i++]=avgK

if (i<MaxNumMergeCand)

mergeCandList[i++]=ZK

It should be noted that upper left coordinates of the object block areconfigured to be (xCb, yCb), the width of the object block is configuredto be cbWidth, and the height of the object block is configured to becbHeight.

The merge candidate selection portion 30362 selects, by means of thefollowing equation, a merge candidate N indicated by the merge indexmerge_idx among the merge candidates included in the merge candidatelist.

N=mergeCandList[merge_idx]

Here, N is a tag indicating the merge candidate, and takes A1, B1, B0,A0, B2, Col, AvgK, ZeroCandK, etc. Motion information of the mergecandidate indicated by the tag N is denoted by (mvLXN[0], mvLXN[1]),predFlagLXN, and refIdxLXN.

The merge candidate selection portion 30362 selects motion information(mvLXN[0], mvLXN[1]), predFlagLXN, and refIdxLXN of the selected mergecandidate as inter-frame prediction parameters of the object block. Themerge candidate selection portion 30362 stores the selected inter-frameprediction parameters in the prediction parameter memory 307, andoutputs the same to the prediction image generation portion 308.

(MMVD Prediction Portion 30373)

The MMVD prediction portion 30373 adds the difference vector mvdLX tothe center vector mvdLX (motion vector serving as the merge candidate)derived by the merge candidate derivation portion 30361 to derive themotion vector.

The MMVD prediction portion 30376 uses syntax base_candidate_idx,direction_idx, and distance_idx from the merge candidate mergeCandList[] and for decoding the encoded data or encoding the encoded data toderive a motion vector mvLX[ ]. In addition, syntax distance_list_idxfor selecting a distance list can be encoded or decoded.

The MMVD prediction portion 30376 can select a center vector mvLN[ ] bymeans of base_candidate_idx.

N=mergeCandList[base_candidate_idx]

The MMVD prediction portion 30376 derives a basic distance (mvdUnit[0],mvdUnit[1]) and a distance DistFromBaseMV.

dir_table_x[ ]={8,−8,0,0,6,−6,−6,6}

dir_table_y[ ]={0,0,8,−8,6,−6,6,−6}

mvdUnit[0]=dir_table_x[direction_idx]

mvdUnit[1]=dir_table_y[direction_idx]

DistFromBaseMV=DistanceTable[distance_idx]

The MMVD prediction portion 30376 derives a difference vector refineMv[].

firstMv[0]=(DistFromBaseMV<<shiftMMVD)*mvdUnit[0]

firstMv[1]=(DistFromBaseMV<<shiftMMVD)*mvdUnit[1]

Here, shiftMMVD is a value for adjusting the size of the differencevector to match accuracy MVPREC of the motion vector in a motioncompensation portion 3091 (interpolation portion).

refineMvL0[0]=firstMv[0]

refineMvL0[1]=firstMv[1]

refineMvL1[0]=−firstMv[0]

refineMvL1[1]=−firstMv[1]

Finally, the MMVD prediction portion 30376 derives the motion vector ofthe MMVD merge candidate from the difference vector refineMvLX and thecenter vector mvLXN as described below.

mvL0[0]=mvL0N[0]+refineMvL0[0]

mvL0[1]=mvL0N[1]+refineMvL0[1]

mvL1[0]=mvL1N[0]+refineMvL1[0]

mvL1[1]=mvL1N[1]+refineMvL1[1]

(AMVP Prediction)

FIG. 9B is a schematic diagram showing components of the AMVP predictionparameter derivation portion 3032 according to this embodiment. The AMVPprediction parameter derivation portion 3032 includes a vector candidatederivation portion 3033 and a vector candidate selection portion 3034.The vector candidate derivation portion 3033 derives prediction vectorcandidates on the basis of the reference picture index refIdxLX andaccording to the motion vector mvLX of the decoded adjacent block storedin the prediction parameter memory 307, and stores the same in aprediction vector candidate list mvpListLX[ ].

The vector candidate selection portion 3034 selects a motion vectormvpListLX[mvp_LX_idx] indicated by a prediction vector index mvp_LX_idxamong prediction vector candidates in the prediction vector candidatelist mvpListLX[ ] as the prediction vector mvpLX. The vector candidateselection portion 3034 outputs the selected prediction vector mvpLX tothe addition portion 3038.

The addition portion 3038 adds the prediction vector mvpLX inputted fromthe AMVP prediction parameter derivation portion 3032 to the decodeddifference vector mvdLX so as to calculate the motion vector mvLX. Theaddition portion 3038 outputs the calculated motion vector mvLX to theprediction image generation portion 308 and the prediction parametermemory 307.

mvLX[0]=mvpLX[0]+mvdLX[0]

mvLX[1]=mvpLX[1]+mvdLX[1]

The motion vector accuracy mode amvr_mode is syntax for performingswitching between accuracies of the motion vector derived in the AMVPmode; for example, when amvr_mode=0, 1, or 2, the accuracy is switchedto ¼ pixels, 1 pixel, and 4 pixels.

When the accuracy of the motion vector is configured to be 1/16, theMvShift (=1<<amvr_mode) derived from amvr_mode can be used to performinverse quantization as described below, and the inverse quantization isused to change motion vector differences having an accuracy of ¼ pixels,1 pixel, and 4 pixels into motion vector differences having an accuracyof 1/16 pixel.

mvdLX[0]=mvdLX[0]<<(MvShift+2)

mvdLX[1]=mvdLX[1]<<(MvShift+2)

It should be noted that the parameter decoding portion 302 can furtherdecode the following syntax to derive mvdLX[ ].

The following are decoded:

abs_mvd_greater0_flag

abs_mvd_minus2

mvd_sign_flag

Then, the parameter decoding portion 302 decodes a difference vector1Mvd[ ] from the syntax by using the following equation.

1Mvd[compIdx]=abs_mvd_greater0_flag[compIdx]*(abs_mvd_minus2[compIdx]+2)*(1−2*mvd_sign_flag[compIdx])

In addition, in the case of a shifting MVD (MotionModelIdc[x][y]==0),the decoded difference vector 1Mvd[ ] is configured to be mvdLX, and inthe case of a control point MVD (MotionModelIdc[x][y]!=0), the decodeddifference vector 1Mvd[ ] is configured to be mvdCpLX.

if (MotionModelIdc[x][y]==0)

mvdLX[x0][y0][compIdx]=1Mvd[compIdx]

else

mvdCpLX[x0][y0][compIdx]=1Mvd[compIdx]<<2

(DMVR)

Next, Decoder side Motion Vector Refinement (DMVR) processing performedby the DMVR portion 30375 is described. When the object CU instructs themerge flag merge_flag to use the merge prediction mode or instructs theskip flag skip_flag to use the skip mode, the DMVR portion 30375 usesthe reference image to correct the motion vector mvLX of the object CUderived by the merge prediction portion 30374.

Specifically, when the prediction parameter derived by the mergeprediction portion 30374 is bidirectional prediction, a prediction imagederived from motion vectors corresponding to two reference pictures isused to correct the motion vector. The corrected motion vector mvLX isprovided to the inter-frame prediction image generation portion 309.

(Triangle Prediction)

Next, the triangle prediction is described. In the triangle prediction,the object CU is split into two triangle prediction units by using adiagonal line or an opposite diagonal line as a boundary. A predictionimage in each triangle prediction unit is derived by weighting eachpixel of the prediction image of the object CU (a rectangular blockincluding the triangle prediction unit) to the position of the pixel andperforming mask processing. For example, a triangular image can bederived from a rectangular image by multiplying by a mask thatconfigures pixels of a triangular region in a rectangular region to be 1and configures pixels of a region outside the triangle to be 0. Inaddition, after an inter-frame prediction image is generated, adaptiveweighting processing is applied to the two regions sandwiching thediagonal line, and a prediction image of the object CU (rectangularblock) is derived by means of adaptive weighting processing employingtwo prediction images. This processing is referred to as trianglesynthesis processing. Then, transform (inverse transform) andquantization (inverse quantization) processing is applied to the entireobject CU. It should be noted that triangle prediction is used only inthe merge prediction mode or the skip mode.

The triangle prediction portion 30377 derives prediction parameterscorresponding to the two triangle regions for the triangle prediction,and provides the same to the inter-frame prediction image generationportion 309. In the triangle prediction, in order to simplify theprocessing, configuration not using bidirectional prediction may bemade. In this case, an inter-frame prediction parameter forunidirectional prediction is derived in a triangle region. It should benoted that the derivation of the two prediction images and the synthesisemploying the prediction image are performed in the motion compensationportion 3091 and the triangle synthesis portion 30952.

The loop filter 305 is a filter provided in an encoding loop, and is afilter for eliminating block distortion and ringing distortion toimprove image quality. The loop filter 305 performs filtering such asde-blocking filtering, Sampling Adaptive Offset (SAO), and Adaptive LoopFiltering (ALF) on the decoded image of the CU generated by the additionportion 312.

The reference picture memory 306 stores the decoded image of the CUgenerated by the addition portion 312 in a predefined position for eachobject picture and each object CU.

The prediction parameter memory 307 stores the prediction parameters ina predefined position for the CTU or the CU of each decoded object.Specifically, the prediction parameter memory 307 stores the parametersdecoded by the parameter decoding portion 302, the prediction modepredMode decoded by the entropy decoding portion 301, etc.

The prediction mode predMode, the prediction parameters, etc., areinputted into the prediction image generation portion 308. In addition,the prediction image generation portion 308 reads the reference picturefrom the reference picture memory 306. The prediction image generationportion 308 uses, in a prediction mode indicated by the prediction modepredMode, the prediction parameters and the read reference picture(reference picture block) to generate a prediction image of the block orthe sub-block. Here, the reference picture block refers to a collection(generally a rectangle, and therefore it is referred to as a block) ofpixels on the reference picture, and is a region referenced forprediction image generation.

(Inter-Frame Prediction Image Generation Portion 309)

When the prediction mode predMode indicates the inter-frame predictionmode, the inter-frame prediction image generation portion 309 uses theinter-frame prediction parameter inputted from the inter-frameprediction parameter decoding portion 303 and the read reference pictureto generate the prediction image of the block or the sub-block by meansof inter-frame prediction.

FIG. 10 is a schematic diagram showing components of the inter-frameprediction image generation portion 309 included in the prediction imagegeneration portion 308 according to this embodiment. The inter-frameprediction image generation portion 309 is configured to include amotion compensation portion (prediction image generation device) 3091and a synthesis portion 3095.

(Motion Compensation)

On the basis of the inter-frame prediction parameters (prediction listuse flag predFlagLX, reference picture index refIdxLX, and motion vectormvLX) inputted from the inter-frame prediction parameter decodingportion 303, the motion compensation portion 3091 (interpolation imagegeneration portion 3091) generates an interpolation image (motioncompensation image) by reading, from the reference picture memory 306, ablock located in a position shifted by the motion vector mvLX from aposition of the object block in a reference picture RefPicLX indicatedby the reference picture index refldxLX. Here, when the accuracy of themotion vector mvLX is not integer accuracy, the motion compensationimage is generated by performing filtering referred to as motioncompensation filtering, which is used to generate pixels in decimalpositions.

The motion compensation portion 3091 firstly derives, by means of thefollowing equations, an integer position (xInt, yInt) and a phase(xFrac, yFrac) corresponding to the coordinates (x, y) in the predictionblock.

x Int=xPb+(mvLX[0]>>(log 2(MVPREC)))+x

xFrac=mvLX[0]&(MVPREC−1)

y Int=yPb+(mvLX[1]>>(log 2(MVPREC)))+y

yFrac=mvLX[1]&(MVPREC−1)

Here, (xPb, yPb) are upper left coordinates of a block having a size ofbW×bH; x=0 . . . bW−1, y=0 . . . bH−1; MVPREC denotes the accuracy ofthe motion vector mvLX (1/MVPREC pixels accuracy). For example,MVPREC=16.

The motion compensation portion 3091 uses an interpolation filter toperform horizontal interpolation processing on a reference picturerefImg so as to derive a temporary image temp[ ][ ]. In the followingequation, X is a sum regarding k of k=0 . . . NTAP−1, shift1 is anormalization parameter for adjusting a range of values, andoffset1=1<<(shift1−1).

temp[x][y]=(ΣmcFilter[xFrac][k]*refImg[xInt+k−NTAP/2+1][yInt]+offset1)>>shift1.Subsequently, the motion compensation portion 3091 derives aninterpolation image Pred[ ][ ] by performing vertical interpolationprocessing on the temporal image temp[ ][ ]. In the following equation,X is a sum regarding k of k=0 . . . NTAP−1, shift2 is a normalizationparameter for adjusting a range of values, and offset2=1<<(shift2−1).

Pred[x][y]=(ΣmcFilter[yFrac][k]*temp[x][y+k−NTAP/2+1]+offset2)>>shift2

The above interpolation image generation processing can be denoted byinterpolations (refImg, xPb, yPb, bW, bH, mvLX).

(Synthesis Portion)

The synthesis portion 3095 generates a prediction image by referring tothe interpolation image provided by the motion compensation portion3091, the inter-frame prediction parameter provided by the inter-frameprediction parameter decoding portion 303, and the intra-frame imageprovided by the intra-frame prediction image generation portion 310, andprovides the generated prediction image to the addition portion 312.

The synthesis portion 3095 includes a combined intra-frame/inter-framesynthesis portion 30951, a triangle synthesis portion 30952, an OBMCportion 30953, and a BIO portion 30954.

(Combined Intra-Frame/Inter-Frame Synthesis Processing)

The combined intra-frame/inter-frame synthesis portion 30951 uses aunidirectional prediction image in AMVP, a prediction image based on theskip mode and the merge prediction mode, and the intra-frame predictionimage to generate a prediction image.

(Triangle Synthesis Processing)

The triangle synthesis portion 30952 generates a prediction imageemploying the above triangle prediction.

(OBMC Processing)

The OBMC portion 30953 uses Overlapped Block Motion Compensation (OBMC)processing to generate a prediction image. The OBMC processing includesthe following processing.

An interpolation image (PU interpolation image) generated by using theinter-frame prediction parameter associated with the object sub-blockand an interpolation image (OBMC interpolation image) generated by usingthe motion parameter of the adjacent sub-block of the object sub-blockare used to generate an interpolation image (motion compensation image)of the object sub-block.

A prediction image is generated by performing weighted average on theOBMC interpolation image and the PU interpolation image.

(BIO Processing)

The BIO portion 30954 generates a prediction image by performingBi-directional Optical flow (BIO, or bidirectional prediction gradientchange) processing. The BIO portion 30954 is described in detail below.

(Weighted Prediction)

In the weighted prediction, a prediction image of the block is generatedby multiplying a motion compensation image PredLX by a weightingcoefficient. When one of the prediction list use flags (predFlagL0 orpredFlagL1) is 1 (unidirectional prediction) and weighted prediction isnot used, processing for matching the motion compensation image PredLX(LX is L0 or L1) with a pixel bit number bitDepth is performed by meansof the following equation.

Pred[x][y]=Clip3(0,(1<<bitDepth)−1,(PredLX[x][y]+offset1)>>shift1)

Here, shift1=14−bitDepth, offset1=1<<(shift1−1).

In addition, when both of the reference list use flags (predFlagL0 andpredFlagL1) are 1 (bidirectional prediction BiPred) and weightedprediction is not used, processing for averaging the motion compensationimages PredL0 and PredL1 and matching an average number thereof with thepixel bit number is performed by means of the following equation.

Pred[x][y]=Clip3(0,(1<<bitDepth)−1,(PredL0[x][y]+PredL1[x][y]+offset2)>>shift2)

Here, shift2=15−bitDepth, offset2=1<<(shift2−1).

In addition, when unidirectional prediction is performed and weightedprediction is performed, the synthesis portion 3095 derives a weightedprediction coefficient w0 and an offset value o0 from the encoded data,and performs processing denoted by the following equation.

Pred[x][y]=Clip3(0,(1<<bitDepth)−1,((PredLX[x][y]*w0+2{circumflex over( )}(log 2WD−1))>>log 2WD)+o0)

Here, log 2WD is a variable denoting a defined shift amount.

In addition, when bidirectional prediction BiPred is performed andweighted prediction is performed, the synthesis portion 3095 derivesweighted prediction coefficients w0, w1, o0, and o1 from the encodeddata, and performs processing denoted by the following equation.

Pred[x][y]=Clip3(0,(1<<bitDepth)−1,(PredL0[x][y]*w0+PredL1[x][y]*w1+((o0+o1+1)<<log2WD))>>(log 2WD+1))

Then, the generated prediction image of the block is outputted to theaddition portion 312.

The inverse quantization/inverse transform portion 311 inverselyquantizes the quantization and transform coefficient inputted from theentropy decoding portion 301 to acquire a transform coefficient. Thequantization and transform coefficient is a coefficient acquired byperforming frequency transform and quantization such as Discrete CosineTransform (DCT), Discrete Sine Transform (DST), etc., on the predictionerror in the encoding processing. The inverse quantization/inversetransform portion 311 performs inverse frequency transform such asinverse DCT, inverse DST, etc., on the acquired transform coefficient tocalculate the prediction error. The inverse quantization/inversetransform portion 311 outputs the prediction error to the additionportion 312.

The addition portion 312 adds the prediction image of the block inputtedfrom the prediction image generation portion 308 to the prediction errorinputted from the inverse quantization/inverse transform portion 311 foreach pixel to generate a decoded image of the block. The additionportion 312 stores the decoded image of the block in the referencepicture memory 306, and outputs the same to the loop filter 305.

(BIO Prediction)

Next, prediction (BIO prediction) using the BIO processing performed bythe BIO portion 30954 is described in detail. The BIO portion 30954generates a prediction image by referring to two prediction images (afirst prediction image and a second prediction image) and a gradientcorrection item in the bidirectional prediction mode.

FIG. 11 is a flowchart illustrating the procedure of derivation of theprediction image.

When the inter-frame prediction parameter decoding portion 303determines unidirectional prediction of L0 (inter_pred_idc is 0 inS101), the motion compensation portion 3091 generates an L0 predictionimage PredL0[x][y] (S102). When the inter-frame prediction parameterdecoding portion 303 determines unidirectional prediction of L1(inter_pred_idc is 1 in S101), the motion compensation portion 3091generates an L1 prediction image PredL1[x][y] (S103). On the other hand,when the inter-frame prediction parameter decoding portion 303determines a bidirectional prediction mode (inter_pred_idc is 2 inS101), S104 is performed. In S104, the synthesis portion 3095 refers tobioAvailableFlag indicating whether to perform BIO processing todetermine whether to perform BIO processing. When bioAvailableFlagindicates TRUE, the BIO portion 30954 performs BIO processing togenerate a bidirectional prediction image (S106). When bioAvailableFlagindicates FALSE, the synthesis portion 3095 generates a prediction imageby means of generation of conventional two-party prediction images(S105).

The inter-frame prediction parameter decoding portion 303 may determinethat bioAvailableFlag indicates TRUE when the L0 reference imagerefImgL0 and the L1 reference image refImgL1 are different referenceimages and are in an opposite direction with respect to the objectpicture. Specifically, when the object image is configured to becurrPic, and the condition of DiffPicOrderCnt(currPic,refImgL0)*DiffPicOrderCnt(currPic, refImgL1)<0 is met, bioAvailableFlagindicates TRUE. Here, DiffPicOrderCnt( ) is a function for deriving adifference of Picture Order Count (POC) of two images as follows.

DiffPicOrderCnt(picA,picB)=PicOrderCnt(picA)−PicOrderCnt(picB)

A condition that the motion vector of the object block is not a motionvector in units of sub-blocks can be added as a condition thatbioAvailableFlag indicates TRUE.

In addition, a condition that the motion vector of the object picture isnot a motion vector in units of sub-blocks can also be added as acondition that bioAvailableFlag indicates TRUE.

In addition, a condition that the sum of an absolute difference betweenthe L0 prediction image and the L1 prediction image of the twoprediction blocks is greater than a specified value can also be added asa condition that bioAvailableFlag indicates TRUE.

In addition, a condition that the prediction image generation mode is aprediction image generation mode in units of blocks can also be added asa condition that bioAvailableFlag indicates TRUE.

Specific processing performed by the BIO portion 30954 is illustrated inFIG. 12 . The BIO processing portion 30954 includes: L0 and L1prediction image generation portion 309541, a gradient image generationportion 309542, a relevant parameter calculation portion 309543, amotion compensation correction value derivation portion 309544, and abidirectional prediction image generation portion 309545. The BIOportion 30954 generates a prediction image from the interpolation imagereceived from the motion compensation portion 3091 and the inter-frameprediction parameter received from the inter-frame prediction parameterdecoding portion 303, and outputs the generated prediction image to theaddition portion 312. It should be noted that the processing of derivinga motion compensation correction value modBIO (motion compensationcorrection image) from a gradient image, performing correction, andderiving prediction images of PredL0 and PredL1 is referred to asbidirectional gradient change processing.

Firstly, L0 and L1 prediction images for BIO processing are generated inthe L0 and L1 prediction image generation portion 309541. In the BIOportion 30954, BIO processing is performed on the basis of the L0 and L1prediction images for each CU unit or each sub-CU unit shown in FIG. 13; however, interpolation image information of two surrounding pixels ofan object CU or an object sub-CU is further needed to acquire agradient. An image having a short tap length such as a bilinear filterinstead of a conventional interpolation filter is used to generateinterpolation image information of this portion, and the interpolationimage information is used for generation of a gradient image describedbelow. In other cases, this portion and an outer side of the picturecopy and use surrounding pixels in the same manner as a filling region.In addition, the BIO processing is in units of N×N pixels below the CUunit or the sub-CU unit, and the processing uses (N+2)×(N+2) pixelsincluding one surrounding pixel.

The gradient image is generated in the gradient image generation portion309542. During the gradient change (optical flow), it is assumed thatthe pixel value of each point does not change and only the positionthereof changes. This can be denoted by a change in a pixel value I inthe horizontal direction (horizontal gradient value 1x) and a positionchange Vx thereof, a change in the pixel value I in the verticaldirection (vertical gradient value 1y) and a position change Vy thereof,and a temporal change 1t of the pixel value I in the following equation.

1x*Vx+1y*Vy+1t=0

The position change (Vx, Vy) is referred to as a correction weightvector (u, v).

Specifically, the gradient image generation portion 309542 derivesgradient images 1x0, 1y0, 1x1, and 1y1 by means of the followingequation. 1x0 and 1x1 denote the gradient in the horizontal direction,and 1y0 and 1y1 denote the gradient in the vertical direction.

1x0[x][y]=(PredL0[x+1][y]−PredL0[x−1][y])>>4

1y0[x][y]=(PredL0[x][y+1]−PredL0[x][y−1])>>4

1x1[x][y]=(PredL1[x+1][y]−PredL1[x−1][y])>>4

1y1[x][y]=(PredL1[x][y+1]−PredL1[x][y−1])>>4

Then, the relevant parameter calculation portion 309543 uses the onesurrounding pixel of each block of N×N pixels in each CU to derivegradient product sums s1, s2, s3, s5, and s6 of (N+2)×(N+2) pixels.

s1=sum(phiX[x][y]*phiX[x][y])

s2=sum(phiX[x][y]*phiY[x][y])

s3=sum(−theta[x][y]*phiX[x][y])

s5=sum(phiY[x][y]*phiY[x][y])

s6=sum(−theta[x][y]*phiY[x][y])

Here, sum(a) denotes the sum of a in the coordinates (x, y) in the blockof (N+2)×(N+2) pixels. In addition,

phiX[x][y]=(1x1[x][y]+1x0[x][y])>>3

phiY[x][y]=(1y1[x][y]+1y0[x][y])>>3

theta[x][y]=−(PredL1[x][y]>>6)+(PredL0[x][y]>>6)

Then, the motion compensation correction value derivation portion 30954uses the derived gradient product sums s1, s2, s3, s5, and s6 to derivea correction weight vector (u, v) in units of N×N pixels.

u=(s3<<3)>>log 2(s1)

v=((s6<<3)−((((u*s2m)<<12)+u*s2s)>>1))>>log 2(s5)

Here, s2 m=s2>>12, s2s=s2&((1<<12)−1).

It should be noted that clipping can be further used to limit the rangeof u and v as shown below.

u=s1>0?Clip3(−th,th,−(s3<<3)>>floor(log 2(s1))):0

v=s5>0?Clip3(−th,th,((s6<<3)−((((u*s2m)<<12)+u*s2s)>>1))>>floor(log2(s5))):0. Here, th=1<<(13−bitDepth).

The motion compensation correction value derivation portion 309544 usesthe correction weight vector (u, v) in units of N×N pixels and thegradient images 1x0, 1y0, 1x1, and 1y1 to derive modBIO[x][y] of themotion compensation correction value of N×N pixels.

modBIO[x][y]=((1x1[x][y]−1x0[x][y])*u+(1y1[x][y]−1y0[x][y])*v+1)>>1(equation A3) or a rounding function can be used to derive modBIO asshown below.

modBIO[x][y]=Round(((1x1[x][y]−1x0[x][y])*u)>>1)+Round(((1y1[x][y]−1y0[x][y])*v)>>1)

The bidirectional prediction image generation portion 309545 uses theabove parameters to derive the pixel value Pred of the prediction imageof N×N pixels by means of the following equation.

In this case, the bidirectional prediction image generation portion309545 uses the above parameters to derive the pixel value Pred of theprediction image of N×N pixels by means of the following equation.

Pred[x][y]=Clip3(0,(1<<bitDepth)−1,(PredL0[x][y]+PredL1[x][y]+modBIO[x][y]+offset2)>>shift2)

Here, shift2=Max(3, 15−bitDepth), offset2=1<<(shift2−1).

Next, another embodiment of prediction (BIO prediction) using the BIOprocessing performed by the BIO portion 30954 is described. In the aboveembodiment, operation is performed correctly when the pixel bit lengthbitDepth is 10 bits; however, in other cases, calculation accuracy notfor an encoding pixel bit length exists, resulting in reduced encodingefficiency. Therefore, as shown below, an internal bit lengthInternalBitDepth independent of the pixel bit length bitDepth is definedand used as the calculation accuracy in the BIO portion, and is fixed;therefore, regardless of bitDepth, the operation is in the range of 32bits. Here, InternalBitDepth is configured to be a value equal to orgreater than 8 and equal to or less than a maximum pixel bit lengthallowed by the decoding device.

Specifically, the gradient image generation portion 309542 performsderivation of the gradient images 1x0, 1y0, 1x1, and 1y1 as follows.

1x0[x][y]=(PredL0[x+1][y]−PredL0[x−1][y])>>shift0

1y0[x][y]=(PredL0[x][y+1]−PredL0[x][y−1])>>shift0

1x1[x][y]=(PredL1[x+1][y]−PredL1[x−1][y])>>shift0

1y1[x][y]=(PredL1[x][y+1]−PredL1[x][y−1])>>shift0

Here, shift0=Max(2, 14−InternalBitDepth).

When an interpolation filter the same as HEVC is used, if bitDepth is inthe range of 8-12 bits, then the operation accuracy of the values ofPredL0 and PredL1 is 14 bits, and is (InternalBitDepth+2) bits whenbitDepth is greater than 12. In this embodiment, a right shift serves asshift1 of the value corresponding to InternalBitDepth, and the operationaccuracy of the gradient images 1x0, 1y0, 1x1, and 1y1 is(InternalBitDepth+1) bits.

Then, the relevant parameter calculation portion 309543 derives thegradient product sums s1, s2, s3, s5, and s6 for each block of N×Npixels in the CU. Here, the one surrounding pixel of the block isfurther used to calculate s1, s2, s3, s5, and s6 according to the sum ofpixels in the block of (N+2)*(N+2) pixels.

s1=sum(phiX[x][y]*phiX[x][y])

s2=sum(phiX[x][y]*phiY[x][y])

s3=sum(−theta[x][y]*phiX[x][y])

s5=sum(phiY[x][y]*phiY[x][y])

s6=sum(−theta[x][y]*phiY[x][y])

Here, sum(a) denotes the sum of a in the coordinates (x, y) in the blockof (N+2)×(N+2) pixels. In addition,

theta[x][y]=−(PredL1[x][y]>>shift4)+(PredL0[x][y]>>shift4)

phiX[x][y]=(1x1[x][y]+1x0[x][y])>>shift5

phiY[x][y]=(1y1[x][y]+1y0[x][y])>>shift5

Here,

shift4=Min(8,InternalBitDepth−4)

shift5=Min(5,InternalBitDepth−7).

In this case, if InternalBitDepth is equal to or greater than 8 andequal to or less than 12, then the operation accuracy of the value oftheta is (19−InternalBitDepth) bits. In addition, if bitDepth of theimage is in the range of 8-12 bits, then the operation accuracy of phiXand phiY is 9 bits. Therefore, when N=4, if bitDepth is in the range of8-12 bits, then the total operation accuracy of s1, s2, and s5 of ablock of 6×6 pixels is about 24 bits; even if the minimum value and themaximum value of PredL0 and PredL1 are in the range of 16 bits, theoperation is also in the range of 32 bits. In addition, when N=4, thetotal operation accuracy of s3 and s6 of the block of 6×6 pixels isabout (34−InternalBitDepth) bits. If the minimum value and the maximumvalue of PredL0 and PredL1 are in the range of 16 bits, then the aboveis implemented by means of 32-bit integer operations.

More specifically, when the case of InternalBitDepth=10 is considered, amethod in which shift0=4, shift4=6, and shift5=3 includes the describedembodiment.

In another configuration made to the relevant parameter calculationportion 309543, the gradient product sums s1, s2, s3, s5, and s6 may notbe acquired by means of a block of (N+2)×(N+2) pixels but by means of ablock of N×N pixels. When N=4, the block is a block of 4×4=16 pixels;therefore, compared with a total of 6×6=36 pixels, operation bitsrequired by sum calculation are reduced by (Ceil(log 2(36))−Ceil(log2(16))=2 bits; therefore,

shift4=Min(7,InternalBitDepth−5)

shift5=Min(4,InternalBitDepth−8)

Even if values that are 1 bit less than the above are used, the abovecan also be implemented by means of 32-bit integer operations. Inaddition, the amount of operation of the gradient product sums can alsobe reduced. As shown in FIG. 14 , the unit of BIO processing is the sameas the reading region; therefore, unlike the case in FIG. 13 , it is notneeded to use a filling region of one surrounding pixel of the object CUor the object sub-CU.

It should be noted that regarding the bilinear filter processing regionof FIG. 14 , it is also possible to perform bilinear filter processingby performing a so-called filling processing in which one surroundingpixel of an inner side of the CU or the sub-CU is copied to one pixel ofan outer side.

Then, the motion compensation correction value derivation portion 309544uses the derived gradient product sums s1, s2, s3, s5, and s6 to derivea correction weight vector (u, v) in units of N×N pixels.

u=(s3<<3)>>log 2(s1)

v=((s6<<3)−((((u*s2m)<<12)+u*s2s)>>1))>>log 2(s5)

Here, s2 m=s2>>12, s2s=s2&((1<<12)−1).

It should be noted that clipping can be further used to limit the rangeof u and v as shown below.

u=s1>0?Clip3(−th,th,−(s3<<3)>>floor(log 2(s1))):0

v=s5>0?Clip3(−th,th,((s6<<3)−((((u*s2m)<<12)+u*s2s)>>1))>>floor(log2(s5))):0. Here,

th=Max(2, 1<<(13−InternalBitDepth)). th is a value independent ofbitDepth; therefore, unlike the described embodiment, the correctionweight vector (u, v) in units of pixels is clipped according to thevalue associated with InternalBitDepth. For example, whenInternalBitDepth=10, th=1<<(13-10)=8; therefore, the clipping shownbelow is performed regardless of the pixel bit length bitDepth.

u=s1>0?Clip3(−8,8,−(s3<<3)>>floor(log 2(s1))):0

v=s5>0?Clip3(−8,8,((s6<<3)−((((u*s2m)<<12)+u*s2s)>>1))>>floor(log2(s5))):0

In this case, the correction weight vector (u, v) in units of pixels isalso related to the accuracy of the motion vector and the value of thequantization width; therefore, a threshold th for limiting thecorrection weight vector (u, v) can be expressed by a function of aquantization width Qp as shown below.

th0=Max(1,1<<(12−InternalBitDepth))

th=th0+floor((Qp−32)/6).

The motion compensation correction value derivation portion 309544 usesthe correction weight vector (u, v) in units of N×N pixels and thegradient images 1x0, 1y0, 1x1, and 1y1 to derive modBIO of the motioncompensation correction value of N×N pixels.

modBIO[x][y]=((1x1[x][y]−1x0[x][y])*u+(1y1[x][y]−1y0[x][y])*v)>>1

The bidirectional prediction image generation portion 309545 uses theabove parameters to derive the pixel value Pred of the prediction imagein units of N×N pixels by means of the following equation.

Pred[x][y]=Clip3(0,(1<<bitDepth)−1,(PredL0[x][y]+PredL1[x][y]+modBIO[x][y]+offset2)>>shift2)

Here, shift2=Max(3, 15−bitDepth), offset2=1<<(shift2−1).

(Components of the Moving Image Encoding Device)

Next, components of the moving image encoding device 11 according tothis embodiment are described. FIG. 15 is a block diagram showingcomponents of the moving image encoding device 11 according to thisembodiment. The moving image encoding device 11 is configured toinclude: a prediction image generation portion 101, a subtractionportion 102, a transform/quantization portion 103, an inversequantization/inverse transform portion 105, an addition portion 106, aloop filter 107, a prediction parameter memory (prediction parameterstorage portion, frame memory) 108, a reference picture memory(reference image storage portion, frame memory) 109, an encodingparameter determination portion 110, a parameter encoding portion 111,and an entropy encoding portion 104.

The prediction image generation portion 101 generates a prediction imageaccording to regions formed by splitting each picture of each image T,namely, according to the CU. The prediction image generation portion 101performs the same action as the prediction image generation portion 308described above, and the description therefor is omitted here.

The subtraction portion 102 subtracts a pixel value of the predictionimage of the block inputted from the prediction image generation portion101 from a pixel value of the image T to generate a prediction error.The subtraction portion 102 outputs the prediction error to thetransform/quantization portion 103.

The transform/quantization portion 103 calculates a transformcoefficient by performing frequency transform on the prediction errorinputted from the subtraction portion 102, and derives a quantizationand transform coefficient by means of quantization. Thetransform/quantization portion 103 outputs the quantization andtransform coefficient to the entropy encoding portion 104 and theinverse quantization/inverse transform portion 105.

The inverse quantization/inverse transform portion 105 is the same asthe inverse quantization/inverse transform portion 311 (FIG. 7 ) in themoving image decoding device 31, and therefore the description thereforis omitted here. The calculated prediction error is inputted to theaddition portion 106.

In the entropy encoding portion 104, the quantization and transformcoefficient is inputted from the transform/quantization portion 103, andencoding parameters are inputted from the parameter encoding portion111. The encoding parameters include, for example, codes such as thereference picture index refIdxLX, the prediction vector indexmvp_LX_idx, the difference vector mvdLX, the motion vector accuracy modeamvr_mode, the prediction mode predMode, and the merge index merge_idx.

The entropy encoding portion 104 performs entropy encoding on splittinginformation, the prediction parameters, the quantization and transformcoefficient, etc., to generate an encoded stream Te, and outputs thesame.

The parameter encoding portion 111 includes a header encoding portion1110, a CT information encoding portion 1111, a CU encoding portion 1112(prediction mode encoding portion), an inter-frame prediction parameterencoding portion 112, and an intra-frame prediction parameter encodingportion 113 not shown in the figure. The CU encoding portion 1112further includes a TU encoding portion 1114.

Schematic operation of each module is described below. The parameterencoding portion 111 performs encoding processing on parameters such asheader information, the splitting information, prediction information,the quantization and transform coefficient, etc.

The CT information encoding portion 1111 encodes QT splittinginformation, MT (BT, TT) splitting information, etc., according to theencoded data.

The CU encoding portion 1112 encodes the CU information, the predictioninformation, a TU split flag split_transform_flag, CU residual flagscbf_cb, cbf_cr, cbf_luma, etc.

When the TU includes the prediction error, the TU encoding portion 1114encodes QP update information (quantization correction value) and aquantization prediction error (residual_coding).

The CT information encoding portion 1111 and the CU encoding portion1112 provide syntax elements such as the inter-frame predictionparameters (the prediction mode predMode, the merge flag merge_flag, themerge index merge_idx, the inter-frame prediction identifierinter_pred_idc, the reference picture index refIdxLX, the predictionvector index mvp_LX_idx, and the difference vector mvdLX), theintra-frame prediction parameters, the quantization and transformcoefficient, etc., to the entropy encoding portion 104.

(Components of the Inter-Frame Prediction Parameter Encoding Portion)

The parameter encoding portion 112 derives the inter-frame predictionparameters on the basis of the prediction parameters inputted from theencoding parameter determination portion 110. The parameter encodingportion 112 includes the same components as the components for theinter-frame prediction parameter decoding portion 303 to derive theinter-frame prediction parameters.

The components of the prediction parameter encoding portion 112 aredescribed. As shown in FIG. 16 , the components include: a parameterencoding control portion 1121, a merge prediction portion 30374, asub-block prediction portion (affine prediction portion) 30372, a DMVRportion 30375, an MMVD prediction portion 30376, a triangle predictionportion 30377, an AMVP prediction parameter derivation portion 3032, anda subtraction portion 1123. The merge prediction portion 30374 has amerge prediction parameter derivation portion 3036. The parameterencoding control portion 1121 includes a merge index derivation portion11211 and a vector candidate index derivation portion 11212. Inaddition, the parameter encoding control portion 1121 derives merge_idx,affine_flag, base_candidate_idx, distance_idx, direction_idx, etc., bymeans of the merge index derivation portion 11211, and derives mvpLX,etc., by means of the vector candidate index derivation portion 11212.The merge prediction parameter derivation portion 3036, the AMVPprediction parameter derivation portion 3032, the affine predictionportion 30372, the MMVD prediction portion 30376, and the triangleprediction portion 30377 may also be collectively referred to as amotion vector derivation portion (motion vector derivation device). Theparameter encoding portion 112 outputs the motion vectors (mvLX,subMvLX), the reference picture index refIdxLX, the inter-frameprediction identifier inter_pred_idc, or information denoting the sameto the prediction image generation portion 101. In addition, theparameter encoding portion 112 outputs merge_flag, skip_flag, merge_idx,inter_pred_idc, refIdxLX, mvp_lX_idx, mvdLX, amvr_mode, and affine_flagto the entropy encoding portion 104.

The merge index derivation portion 11211 derives the merge indexmerge_idx, and outputs the same to the merge prediction parameterderivation portion 3036 (merge prediction portion). The vector candidateindex derivation portion 11212 derives the prediction vector indexmvp_lX_idx.

The merge prediction parameter derivation portion 3036 derives theinter-frame prediction parameter on the basis of the merge indexmerge_idx.

The AMVP prediction parameter derivation portion 3032 derives theprediction vector mvpLX on the basis of the motion vector mvLX. The AMVPprediction parameter derivation portion 3032 outputs the predictionvector mvpLX to the subtraction portion 1123. It should be noted thatthe reference picture index refIdxLX and the prediction vector indexmvp_lX_idx are outputted to the entropy encoding portion 104.

The affine prediction portion 30372 derives the inter-frame predictionparameters (affine prediction parameter) of the sub-block.

The subtraction portion 1123 subtracts the prediction vector mvpLXserving as an output of the AMVP prediction parameter derivation portion3032 from the motion vector mvLX inputted by the encoding parameterdetermination portion 110 to generate a difference vector mvdLX. Thedifference vector mvdLX is outputted to the entropy encoding portion104.

The addition portion 106 adds the pixel value of the prediction image ofthe block inputted from the prediction image generation portion 101 tothe prediction error inputted from the inverse quantization/inversetransform portion 105 for each pixel so as to generate a decoded image.The addition portion 106 stores the generated decoded image in thereference picture memory 109.

The loop filter 107 performs de-blocking filtering, SAO, and ALF on thedecoded image generated by the addition portion 106. It should be notedthat the loop filter 107 does not necessarily include the above threefilters, for example, the loop filter 107 may include only a de-blockingfilter.

The prediction parameter memory 108 stores the prediction parametersgenerated by the encoding parameter determination portion 110 in apredefined position for each object picture and each CU.

The reference picture memory 109 stores the decoded image generated bythe loop filter 107 in a predefined position for each object picture andeach CU.

The encoding parameter determination portion 110 selects one of aplurality of sets of encoding parameters. The encoding parameters referto the aforementioned QT, BT, or TT splitting information, predictionparameters, or parameters generated in association with the same andserving as encoding objects. The prediction image generation portion 101uses these encoding parameters to generate the prediction image.

The encoding parameter determination portion 110 calculates an RD costvalue denoting an information size and the encoding error for each ofthe plurality of sets. The encoding parameter determination portion 110selects a set of encoding parameters having a lowest calculated costvalue. Therefore, the entropy encoding portion 104 uses the selected setof encoding parameters as the encoded stream Te, and outputs the same.The encoding parameter determination portion 110 stores the determinedencoding parameters in the prediction parameter memory 108.

It should be noted that a part of the moving image encoding device 11and the moving image decoding device 31 in the above embodiment, forexample, the entropy decoding portion 301, the parameter decodingportion 302, the loop filter 305, the prediction image generationportion 308, the inverse quantization/inverse transform portion 311, theaddition portion 312, the prediction image generation portion 101, thesubtraction portion 102, the transform/quantization portion 103, theentropy encoding portion 104, the inverse quantization/inverse transformportion 105, the loop filter 107, the encoding parameter determinationportion 110, and the parameter encoding portion 111 can be implementedby means of a computer. In this case, it can be implemented by recordinga program for implementing the control function in a computer-readablerecording medium and causing a computer system to read and execute theprogram recorded in the recording medium. It should be noted that thedescribed “computer system” refers to a computer system built in any oneof the moving image encoding device 11 and the moving image decodingdevice 31 and including an OS and hardware such as a peripheralapparatus. In addition, the “computer-readable recording medium” refersto a removable medium such as a floppy disk, a magneto-optical disk, anROM, and a CD-ROM and a storage device such as a hard disk built in thecomputer system. Moreover, the “computer-readable recording medium” mayalso include a recording medium for dynamically storing a program for ashort time period such as a communication line used to transmit aprogram over a network such as the Internet or over a telecommunicationline such as a telephone line, and may also include a recording mediumfor storing a program for a fixed time period such as a volatile memoryin the computer system for functioning as a server or a client in such acase. In addition, the program described above may be a program forimplementing a part of the functions described above, and may also be aprogram capable of implementing the functions described above incombination with a program already recorded in the computer system.

In addition, the moving image encoding device 11 and the moving imagedecoding device 31 in the above embodiment may be partially orcompletely implemented as integrated circuits such as Large ScaleIntegration (LSI) circuits. The functional blocks of the moving imageencoding device 11 and the moving image decoding device 31 may beindividually implemented as processors, or may be partially orcompletely integrated into a processor. In addition, the circuitintegration method is not limited to LSI, and the integrated circuitsmay be implemented as dedicated circuits or a general-purpose processor.In addition, with advances in semiconductor technology, a circuitintegration technology with which LSI is replaced appears, and thereforean integrated circuit based on the technology may also be used.

An embodiment of the present invention has been described in detailabove with reference to the accompanying drawings; however, the specificconfiguration is not limited to the above embodiment, and variousamendments can be made to a design without departing from the scope ofthe gist of the present invention.

Application Examples

The moving image encoding device 11 and the moving image decoding device31 described above can be used in a state of being mounted on variousdevices for transmitting, receiving, recording, and reproducing a movingimage. It should be noted that the moving image may be a natural movingimage captured by a video camera or the like, or may be an artificialmoving image (including CG and GUI) generated by means of a computer orthe like.

Firstly, with reference to FIGS. 2A to 2B, descriptions of the movingimage encoding device 11 and the moving image decoding device 31, asdescribed above, which may be used to transmit and receive the movingimage, is provided.

FIG. 2A is a block diagram showing components of a transmitting devicePROD_A equipped with the moving image encoding device 11. As shown FIG.2A, the transmitting device PROD_A includes: an encoding portion PROD_A1for acquiring encoded data by encoding the moving image, a modulationportion PROD_A2 for acquiring a modulation signal by using the encodeddata acquired by the encoding portion PROD_A1 to modulate a carrier, anda transmitting portion PROD_A3 for transmitting the modulation signalacquired by the modulation portion PROD_A2. The moving image encodingdevice 11 described above is used as the encoding portion PROD_A1.

As a source for providing the moving image inputted to the encodingportion PROD_A1, the transmitting device PROD_A may further include: avideo camera PROD_A4 for capturing a moving image, a recording mediumPROD_A5 on which the moving image is recorded, an input terminal PROD_A6for inputting a moving image from the external, and an image processingportion A7 for generating or processing an image. FIG. 2A exemplarilyshows that the transmitting device PROD_A includes all of thesecomponents, but a part of these components can be omitted.

It should be noted that the recording medium PROD_A5 may be a medium onwhich a moving image not encoded is recorded, or may be a medium onwhich a moving image encoded by using an encoding method for recordingdifferent from the encoding method for transmission is recorded. In thelatter case, a decoding portion (not shown) for decoding, according tothe encoding method for recording, the encoded data read from therecording medium PROD_A5 may be provided between the recording mediumPROD_A5 and the encoding portion PROD_A1.

FIG. 2B is a block diagram showing components of a receiving devicePROD_B equipped with the moving image decoding device 31. As shown inFIG. 2B, the receiving device PROD_B includes: a receiving portionPROD_B1 for receiving the modulation signal, a demodulation portionPROD_B2 for acquiring the encoded data by demodulating the modulationsignal received by the receiving portion PROD_B1, and a decoding portionPROD_B3 for acquiring the moving image by decoding the encoded dataacquired by the demodulation portion PROD_B2. The moving image decodingdevice 31 described above is used as the decoding portion PROD_B3.

The receiving device PROD_B serves as a destination of provision of themoving image outputted by the decoding portion PROD_B3, and may furtherinclude a display PROD_B4 for displaying the moving image, a recordingmedium PROD_B5 for recording the moving image, and an output terminalPROD_B6 for outputting the moving image to the external. FIG. 2Bexemplarily shows that the receiving device PROD_B includes all of thesecomponents, but a part of these components can be omitted.

It should be noted that the recording medium PROD_B5 may be a medium onwhich a moving image not encoded is recorded, or may be a medium onwhich a moving image encoded by using an encoding method for recordingdifferent from the encoding method for transmission is recorded. In thelatter case, an encoding portion (not shown) for encoding, according tothe encoding method for recording, the moving image acquired from thedecoding portion PROD_B3 may be provided between the decoding portionPROD_B3 and the recording medium PROD_B5.

It should be noted that a transmission medium for transmitting themodulation signal may be wireless or wired. In addition, a transmissionscheme for transmitting the modulation signal may be broadcasting (here,referred to a transmission scheme of which the transmission destinationis not determined in advance) or communication (here, referred to atransmission scheme of which the transmission destination is determinedin advance). That is, transmission of the modulation signal may beimplemented by means of any one of wireless broadcasting, wiredbroadcasting, wireless communication, and wired communication.

For example, a broadcast station (broadcast apparatus and thelike)/receiving station (television receiver and the like) of digitalterrestrial broadcasting is an example of the transmitting devicePROD_A/receiving device PROD_B transmitting or receiving the modulationsignal by means of wireless broadcasting. In addition, a broadcaststation (broadcast apparatus and the like)/receiving station (televisionreceiver and the like) of cable television broadcasting is an example ofthe transmitting device PROD_A/receiving device PROD_B transmitting orreceiving the modulation signal by means of wired broadcasting.

In addition, a server (workstation and the like)/client (televisionreceiver, personal computer, smart phone, and the like) using a Video OnDemand (VOD) service and a moving image sharing service on the Internetis an example of the transmitting device PROD_A/receiving device PROD_Btransmitting or receiving the modulation signal by means ofcommunication (generally, a wireless or wired transmission medium isused in LAN, and a wired transmission medium is used in WAN). Here, thepersonal computer includes a desktop PC, a laptop PC, and a tablet PC.In addition, the smart phone also includes a multi-functional mobilephone terminal.

It should be noted that the client using the moving image sharingservice has a function for decoding encoded data downloaded from theserver and displaying the same on a display and a function for encodinga moving image captured by a video camera and uploading the same to theserver. That is, the client using the moving image sharing servicefunctions as both the transmitting device PROD_A and the receivingdevice PROD_B.

Next, with reference to FIGS. 3A to 3B, descriptions of the moving imageencoding device 11 and the moving image decoding device 31, as describedabove, which may be used to record and reproduce the moving image, isprovided.

FIG. 3A is a block diagram showing components of a recording devicePROD_C equipped with the moving image encoding device 11 describedabove. As shown FIG. 3A, the recording device PROD_C includes: anencoding portion PROD_C1 for acquiring encoded data by encoding themoving image and a writing portion PROD_C2 for writing the encoded dataacquired by the encoding portion PROD_C1 in a recording medium PROD_M.The moving image encoding device 11 described above is used as theencoding portion PROD_C1.

It should be noted that the recording medium PROD_M may be (1) arecording medium built in the recording device PROD_C such as a HardDisk Drive (HDD) and a Solid-State Drive (SSD), may also be (2) arecording medium connected to the recording device PROD_C such as an SDmemory card and a Universal Serial Bus (USB) flash memory, and may alsobe (3) a recording medium loaded into a drive device (not shown) builtin the recording device PROD_C such as a Digital Versatile Disc (DVD,registered trademark) and a Blu-ray Disc (BD, registered trademark).

In addition, as a source for providing the moving image inputted to theencoding portion PROD_C1, the recording device PROD_C may furtherinclude: a video camera PROD_C3 for capturing a moving image, an inputterminal PROD_C4 for inputting a moving image from the external, areceiving portion PROD_C5 for receiving a moving image, and an imageprocessing portion PROD_C6 for generating or processing an image. FIG.3A exemplarily shows that the recording device PROD_C includes all ofthese components, but a part of these components can be omitted.

It should be noted that the receiving portion PROD_C5 can receive anun-encoded moving image, and can also receive encoded data encoded byusing an encoding method for transmission different from the encodingmethod for recording. In the latter case, a decoding portion fortransmission (not shown) for decoding the encoded data encoded by usingthe encoding method for transmission may be provided between thereceiving portion PROD_C5 and the encoding portion PROD_C1.

Examples of such recording device PROD_C include: a DVD recorder, a BDrecorder, a Hard Disk Drive (HDD) recorder, etc. (in this case, theinput terminal PROD_C4 or the receiving portion PROD_C5 is a main sourcefor providing the moving image). In addition, a portable video camera(in this case, the video camera PROD_C3 is the main source for providingthe moving image), a personal computer (in this case, the receivingportion PROD_C5 or the image processing portion C6 is the main sourcefor providing the moving image), and a smart phone (in this case, thevideo camera PROD_C3 or the receiving portion PROD_C5 is the main sourcefor providing the moving image) are also included in the examples ofsuch recording device PROD_C.

FIG. 3B is a block diagram showing components of a reproducing devicePROD_D equipped with the moving image decoding device 31 describedabove. As shown FIG. 3B, the reproducing device PROD_D includes: areading portion PROD_D1 for reading the encoded data having been writtenin the recording medium PROD_M and a decoding portion PROD_D2 foracquiring the moving image by decoding the encoded data read by thereading portion PROD_D1. The moving image decoding device 31 describedabove is used as the decoding portion PROD_D2.

It should be noted that the recording medium PROD_M may be (1) arecording medium built in the reproducing device PROD_D such as an HDDand an SSD, may also be (2) a recording medium connected to thereproducing device PROD_D such as an SD memory card and a USB flashmemory, and may also be (3) a recording medium loaded into a drivedevice (not shown) built in the reproducing device PROD_D such as a DVDand a BD.

In addition, as a destination of provision of the moving image outputtedby the decoding portion PROD_D2, the reproducing device PROD_D mayfurther include: a display PROD_D3 for displaying the moving image, anoutput terminal PROD_D4 for outputting the moving image to the external,and a transmitting portion PROD_D5 for transmitting the moving image.FIG. 3B exemplarily shows that the reproducing device PROD_D includesall of these components, but a part of these components can be omitted.

It should be noted that the transmitting portion PROD_D5 can transmit anun-encoded moving image, and can also transmit encoded data encoded byusing an encoding method for transmission different from the encodingmethod for recording. In the latter case, an encoding portion (notshown) for encoding the moving image by using the encoding method fortransmission may be provided between the decoding portion PROD_D2 andthe transmitting portion PROD_D5.

Examples of such reproducing device PROD_D include a DVD player, a BDplayer, an HDD player, and the like (in this case, the output terminalPROD_D4 connected to a television receiver and the like is a maindestination of provision of the moving image). In addition, a televisionreceiver (in this case, the display PROD_D3 is the main destination ofprovision of the moving image), a digital signage (also referred to asan electronic signage or an electronic bulletin board, and the displayPROD_D3 or the transmitting portion PROD_D5 is the main destination ofprovision of the moving image), a desktop PC (in this case, the outputterminal PROD_D4 or the transmitting portion PROD_D5 is the maindestination of provision of the moving image), a laptop or tablet PC (inthis case, the display PROD_D3 or the transmitting portion PROD_D5 isthe main destination of provision of the moving image), and a smartphone (in this case, the display PROD_D3 or the transmitting portionPROD_D5 is the main destination of provision of the moving image) arealso included in the examples of such reproducing device PROD_D.

(Hardware Implementation and Software Implementation)

In addition, the blocks in the moving image decoding device 31 and themoving image encoding device 11 described above may be implemented byhardware by using a logic circuit formed on an integrated circuit (ICchip), or may be implemented by software by using a Central ProcessingUnit (CPU).

In the latter case, the devices described above include: a CPU forexecuting commands of a program for implementing the functions, a ReadOnly Memory (ROM) for storing the program, a Random Access Memory (RAM)for loading the program, and a storage device (storage medium) such as amemory for storing the program and various data. The objective of theembodiments of the present invention can be attained by performing thefollowing: software for implementing the functions described above,namely program code of a control program for the above devices(executable program, intermediate code program, source program), isrecoded in a recording medium in a computer-readable manner, therecording medium is provided to the above devices, and the computer (orCPU or MPU) reads the program code recorded in the recording medium andexecutes the same.

Examples of the recording medium described above include: tapes such asa magnetic tape and a cassette tape, disks or discs including a magneticdisk such as a floppy disk (registered trademark)/hard disk and anoptical disc such as a Compact Disc Read-Only Memory(CD-ROM)/Magneto-Optical (MO) disc/Mini Disc (MD)/Digital Versatile Disc(DVD, registered trademark)/CD Recordable (CD-R)/Blu-ray Disc(registered trademark), cards such as an IC card (including a memorycard)/optical card, semiconductor memories such as a mask ROM/ErasableProgrammable Read-Only Memory (EPROM)/Electrically Erasable andProgrammable Read-Only Memory (EEPROM)/flash ROM, or logic circuits suchas a Programmable logic device (PLD) and a Field-Programmable Gate Array(FPGA).

In addition, the devices described above may also be configured to beconnectable to a communication network and to be provided with the aboveprogram code by means of the communication network. The communicationnetwork is not specifically limited as long as the program code can betransmitted. For example, the Internet, an intranet, an extranet, aLocal Area Network (LAN), an Integrated Services Digital Network (ISDN),a Value-Added Network (VAN), a Community Antenna television/CableTelevision (CATV) communication network, a virtual private network, atelephone network, a mobile communication network, a satellitecommunication network, and the like can be used. In addition,transmission media forming the communication network are not limited toa specific configuration or type as long as the program code can betransmitted. For example, a wired medium such as Institute of Electricaland Electronic Engineers (IEEE) 1394, a USB, a power-line carrier, acable TV line, a telephone line, and an Asymmetric Digital SubscriberLine (ADSL) or a wireless medium such as an infrared-ray includingInfrared Data Association (IrDA) and a remote controller, Bluetooth(registered trademark), IEEE 802.11 wireless communication, High DataRate (HDR), Near-Field Communication (NFC), Digital Living NetworkAlliance (DLNA, registered trademark), a mobile telephone network, asatellite circuit, and a terrestrial digital broadcast network can alsobe used. It should be noted that the embodiments of the presentinvention may also be implemented in a form of a computer data signalembedded in a carrier wave in which the above program code is embodiedby electronic transmission.

The embodiments of the present invention are not limited to the aboveembodiments, and can be variously modified within the scope of theclaims. That is, embodiments acquired by combining technical solutionswhich are adequately modified within the scope of the claims are alsoincluded in the technical scope of the present invention.

INDUSTRIAL APPLICABILITY

Embodiments of the present invention can be preferably applied to amoving image decoding device for decoding encoded data acquired byencoding image data and a moving image encoding device for generatingencoded data acquired by encoding image data. In addition, embodimentsof the present invention can be preferably applied to a data structureof the encoded data generated by the moving image encoding device andreferred to by the moving image decoding device.

CROSS-REFERENCE TO RELATED APPLICATIONS

The present application claims priority to Japanese Patent ApplicationJP 2018-232640 filed on Dec. 12, 2018 and Japanese Patent Application JP2019-000704 filed on Jan. 7, 2019, which are incorporated in thespecification by reference in their entireties.

REFERENCE NUMERAL LIST

-   31 Image decoding device-   301 Entropy decoding portion-   302 Parameter decoding portion-   3020 Header decoding portion-   303 Inter-frame prediction parameter decoding portion-   304 Intra-frame prediction parameter decoding portion-   308 Prediction image generation portion-   309 Inter-frame prediction image generation portion-   310 Intra-frame prediction image generation portion-   311 Inverse quantization/inverse transform portion-   312 Addition portion-   11 Image encoding device-   101 Prediction image generation portion-   102 Subtraction portion-   103 Transform/quantization portion-   104 Entropy encoding portion-   105 Inverse quantization/inverse transform portion-   107 Loop filter-   110 Encoding parameter determination portion-   111 Parameter encoding portion-   112 Inter-frame prediction parameter encoding portion-   113 Intra-frame prediction parameter encoding portion-   1110 Header encoding portion-   1111 CT information encoding portion-   1112 CU encoding portion (prediction mode encoding portion)-   1114 TU encoding portion-   30954 BIO portion-   309541 L0, L1 prediction image generation portion-   309542 Gradient image generation portion-   309543 Relevant parameter calculation portion-   309544 Motion compensation correction value derivation portion-   309545 Bidirectional prediction image generation portion

What is claimed is:
 1. A moving image decoding device for generatingprediction images, the moving image decoding device comprising:prediction image generation circuitry for generating a first predictionimage and a second prediction image; gradient image generation circuitryfor performing bidirectional prediction gradient change predictionprocessing by: generating a first gradient image by calculating a firstdifference value of two horizontally neighboring samples of each of aplurality of current samples of the first prediction image, whereincalculating the first difference value comprises performing a firstright shifting by a first shift value of six, generating a secondgradient image by calculating a second difference value of twovertically neighboring samples of each of the plurality of currentsamples of the first prediction image, wherein calculating the seconddifference value comprises performing a second right shifting by thefirst shift value, generating a third gradient image by calculating athird difference value of two horizontally neighboring samples of eachof a plurality of current samples of the second prediction image,wherein calculating the third difference value comprises performing athird right shifting by the first shift value, and generating a fourthgradient image by calculating a fourth difference value of twovertically neighboring samples of each of the plurality of currentsamples of the second prediction image, wherein calculating the fourthdifference value comprises performing a fourth right shifting by thefirst shift value; motion compensation correction value derivationcircuitry that: use the first prediction image, the second predictionimage, and a second shift value of four to generate a first intermediateimage, use the first gradient image, the third gradient image, and athird shift value of one to generate a second intermediate image, usethe second gradient image, the fourth gradient image, and the thirdshift value to generate a third intermediate image, use the firstintermediate image, the second intermediate image, and the thirdintermediate image to derive motion information, and use the motioninformation, the first gradient image, the second gradient image, thethird gradient image, and the fourth gradient image to derive a motioncompensation correction value; and prediction image generation circuitrythat use the first prediction image, the second prediction image, andthe motion compensation correction value to generate a third predictionimage, wherein the first shift value, the second shift value, and thethird shift value are derived based on a pixel bit length bitDepth ofeight.
 2. The moving image decoding device according to claim 1, whereinthe motion compensation correction value derivation uses a firstthreshold of 16 to derive the motion information.
 3. The moving imagedecoding device according to claim 1, wherein an encoding object imageis restored by adding a residual image to or subtracting the residualimage from the generated third prediction image.
 4. A moving imagedecoding method for generating prediction images, the moving imagedecoding method comprising: generating a first prediction image and asecond prediction image; performing bidirectional prediction gradientchange prediction processing by: generating a first gradient image bycalculating a first difference value of two horizontally neighboringsamples of each of a plurality of current samples of the firstprediction image, wherein calculating the first difference valuecomprises performing a first right shifting by a first shift value ofsix, generating a second gradient image by calculating a seconddifference value of two vertically neighboring samples of each of theplurality of current samples of the first prediction image, whereincalculating the second difference value comprises performing a secondright shifting by the first shift value, generating a third gradientimage by calculating a third difference value of two horizontallyneighboring samples of each of a plurality of current samples of thesecond prediction image, wherein calculating the third difference valuecomprises performing a third right shifting by the first shift value,and generating a fourth gradient image by calculating a fourthdifference value of two vertically neighboring samples of each of theplurality of current samples of the second prediction image, whereincalculating the fourth difference value comprises performing a fourthright shifting by the first shift value; using the first predictionimage, the second prediction image, and a second shift value of four togenerate a first intermediate image; using the first gradient image, thethird gradient image, and a third shift value of one to generate asecond intermediate image; using the second gradient image, the fourthgradient image, and the third shift value to generate a thirdintermediate image; using the first intermediate image, the secondintermediate image, and the third intermediate image to derive motioninformation; using the motion information, the first gradient image, thesecond gradient image, the third gradient image, and the fourth gradientimage to derive a motion compensation correction value; and using thefirst prediction image, the second prediction image, and the motioncompensation correction value to generate a third prediction image,wherein the first shift value, the second shift value, and the thirdshift value are derived based on a pixel bit length bitDepth of eight.5. The moving image decoding method according to claim 4, furthercomprising: using a first threshold of 16 to derive the motioninformation.